/**
 * Created by lenovo on 2017/4/28.
 */
(function(){
    //页面的高度
    parent.$('#content').css('height','1000px').css('width','960px');

    /*保存信息*/
    $('.save').on('click',function(){
        parent.$('iframe').attr('src','./html/clubPreview.html');
    })

    /*添加银行卡*/
    $('.re_card .span2').on('click',function(){
        parent.$('iframe').attr('src','./html/addBankCard.html');
    })
	var clubId=config.sessionStroageGet("clubId");
    //添加标签
    $('.re_tag .span2').on('click',function(){
        var input = $('.re_tag .input1').val();
       if(input!=''){
	        $.ajax({
	        	      url:config.baseUrl+'/settings/addClubLabel',
			      type:'GET',
			      data:{'clubId':clubId,'labelName':input},
			      dataType:'json',
			      success:function(result){
			          if(result){
			                getClublabelList();
			            }
			        },
			     error:function(result){
			             console.log("标签添加失败");
			        }
	        })
       }
    })

    //删除标签
    $('.own_tag').on('click','.tag_remove',function(){
       	 var culdId = $(this).parent().attr("data-cId")
    	      $.ajax({
	        	      url:config.baseUrl+'/settings/deleteClubLabel',
			      type:'GET',
			      data:{'id':culdId},
			      dataType:'json',
			      success:function(result){
			          if(result){			                
			                getClublabelList();
			            }
			        },
			     error:function(result){
			             console.log("标签删除失败");
			        }
	        })
    	

    })

    //俱乐部信息接口
    $.ajax({
        url:'',
        type:'',
        dataType:'json',
        success:function(result){

        },
        error:function(result){

        }
    })
    
     //俱乐部标签接口
  var getClublabelList = function(){
  	$.ajax({
        url:config.baseUrl+'/settings/getClubLabelList',
        type:'GET',
        data:{'clubId':clubId},
        dataType:'json',
        success:function(result){
           if(result){
               var html="";
               for(var i = 0;i<result.body.length;i++){
               	   html+='<span class="span3" data-cId='+result.body[i].id+'>'+result.body[i].name+'<span class="tag_remove">×</span></span>'
               }
               $('.own_tag .own_tag-contain').html(html); 
            }
        },
        error:function(result){
             console.log("标签生成失败");
        }
    });
   }
  getClublabelList();
    
    
})()